package me.zk.practice1.s;

/**
 * @Author: zhang kai
 * @Date: 2023/05/06
 * @Description:
 */
public class S13 {
    public static void main(String[] args) {
        System.out.println(validPalindrome("abbc"));
    }
    public static boolean validPalindrome(String s) {

        int left = 0;
        int right = s.length()-1;
        while (left <= right){
            if (s.charAt(left) != s.charAt(right)) {
              return valid(s,left,right-1) || valid(s,left+1, right);
            }
            left++;
            right--;
        }

        return true;


    }

    private static boolean valid(String s, int l, int r) {
        while (l <= r) {
            if (s.charAt(l) != s.charAt(r)) {
                return false;
            }
            l++;
            r--;
        }
        return true;

    }

}
